﻿using System.Collections.Generic;
using System.Text;

namespace tiny_compiler
{
	public class Compiler
	{
		public void Add(IOperator _operator)
		{
			m_operators.Add(_operator);
		}

		public string Compile()
		{
			foreach (var op in m_operators)
				op.Resolve(m_operators);

			foreach (var op in m_operators)
				op.Append(m_data);

			return m_data.ToString();
		}

		public const int NameLength = 1;
		public const int NumberLength = 4;
		public const string NumberFormat = "0000;-000";
		public const int LengthLength = 1;

		public const string CursorName = "a";
		public const string PrintName = "b";
		public const string ReadKeyName = "c";
		public const string CopyName = "d";
		public const string AddName = "e";
		public const string CompareName = "f";

		private StringBuilder m_data = new StringBuilder();
		private List<IOperator> m_operators = new List<IOperator>();
	}
}